Skip to content

Per-magazine attachment coordinates + two reload-end glitch fixes - #9

Open
Gamaun007 wants to merge 3 commits into
Verdatim25:devfrom
Gamaun007:feature/per-mag-coordinates-dev
Open

Per-magazine attachment coordinates + two reload-end glitch fixes#9
Gamaun007 wants to merge 3 commits into
Verdatim25:devfrom
Gamaun007:feature/per-mag-coordinates-dev

Conversation

@Gamaun007

@Gamaun007 Gamaun007 commented Jul 8, 2026

Copy link
Copy Markdown

Two small, backward-compatible improvements to scripted_magazines.script, ported onto the current dev (0.2) refactor.

1. Per-magazine attachment coordinates

Right now every mag on a gun shares one offset (s_magazine_positions_<bone>, etc). If two mags for the same gun have different pivots/sizes, one of them sits wrong.

This adds an optional per-mag override: any offset field can be suffixed with the magazine's section —

s_magazine_positions_<bone>_<mag_section> = x,y,z
s_magazine_rotations_<bone>_<mag_section> = x,y,z
s_magazine_scale_<bone>_<mag_section>     = float
s_magazine_parent_bone_<bone>_<mag_section> = <bone>

Resolution per field: if the suffixed key exists it's used, otherwise it falls back to the shared s_magazine_<field>_<bone> key. Guns that only define the shared keys are completely unaffected — same behaviour as before.

The suffixed key is resolved against the loaded mag. During the mid-reload swap the loaded mag is still nil/old, so it falls back to the section the core already captures (incoming_mag_section / pending_swap_mag_section), so the model lands on its final coords immediately instead of jumping when the data commits. The swap path (change_specific_mag_model) applies the per-mag scale for the same reason. Documented with an AK example in 2_guide_on_adding_to_new_anim_sets.ltx.

2. Two reload-end visual glitch fixes

  • Skip set_model when the path is unchanged (both update_scripted_magazines and change_specific_mag_model): re-setting a live attachment's model resets its transform until the position/rotation setters re-apply next tick, rendering one frame at the default pose.
  • Don't scale the attachment to 0 while a reload is in progress: at reload end the idle anim triggers the no-mag refresh BEFORE the new mag data commits (same frame), which hid the freshly inserted mag until the next animation change (movement). Guarded with magazines.action_in_progress().

Both are guard-only changes; the normal paths are untouched.

Gamaun007 and others added 3 commits July 8, 2026 17:20
Each offset field (positions/rotations/scale/parent_bone) can now be
overridden per magazine section via keys suffixed with the mag section:
  s_magazine_<field>_<bone>_<mag_section> = ...
Unsuffixed shared keys keep working exactly as before and remain the
fallback, so existing weapon configs are unaffected.

The suffixed key is resolved against the loaded mag; during the mid-reload
swap the loaded mag is still nil/old, so it falls back to the incoming/
pending section the core already captures (incoming_mag_section /
pending_swap_mag_section) - the model lands on its final coords immediately
instead of jumping when the data commits. The swap path
(change_specific_mag_model) applies the per-mag scale for the same reason.

Documented in 2_guide_on_adding_to_new_anim_sets.ltx.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1. Skip set_model when the model path is unchanged (both the full refresh
   in update_scripted_magazines and the mid-reload swap in
   change_specific_mag_model): re-setting a live attachment's model resets
   its transform until the position/rotation setters re-apply, rendering
   one frame at the default pose.

2. Don't scale the attachment to 0 while a Mags Reloaded reload is still in
   progress: at reload end the idle anim triggers the no-mag refresh BEFORE
   the new mag data is committed (same frame), which hid the freshly
   inserted mag until the next animation change (movement).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
change_specific_mag_model swapped the model (and scale) mid-reload but left
position/rotation at the previous mag's pose until the next idle refresh, so
a mag could sit visibly wrong during the reload. Apply the per-mag
position/rotation there too (same suffixed-key resolution), so the swapped
model lands on its final pose immediately - matching the full refresh in
update_scripted_magazines.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant